package com.feign;

import com.alibaba.fastjson.JSONObject;
import feign.Headers;
import feign.RequestLine;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.FeignClientsConfiguration;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;

import java.net.URI;

/**
 * @author Fang Ruichuan
 * @date 2022-10-09 10:26
 */
@FeignClient(name = "dynamicFeignClient", configuration = FeignClientsConfiguration.class)
public interface DynamicFeignClient {

    // 发送GET请求
    @RequestLine("GET")
    @GetMapping("/product/{id}")
    String getProductById(@PathVariable("id") Long id);

    // 发送POST请求
    @RequestLine("POST")
    @Headers(value = "Content-Type: application/json;charset=UTF-8")
    String requestPOST(URI baseUri, @RequestBody JSONObject args);

    // 发送webservice-SOAP请求
    @RequestLine("POST")
    @Headers(value = "Content-Type: text/xml;charset=UTF-8")
    String requestSOAP(URI baseUri, @RequestBody String params);
}
